package com.basic.business.dingTalk.service.impl;

import com.basic.business.dingTalk.domain.TDingTalkMgmt;
import com.basic.business.dingTalk.mapper.TDingTalkMgmtMapper;
import com.basic.business.dingTalk.service.ITDingTalkMgmtService;
import com.basic.common.constant.CacheConstants;
import com.basic.common.core.redis.RedisCacheUtils;
import com.basic.common.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * 钉钉配置Service业务层处理
 *
 * @author zhaoxy_jn@163.com
 */
@Service
public class TDingTalkMgmtServiceImpl extends BaseServiceImpl<TDingTalkMgmtMapper, TDingTalkMgmt> implements ITDingTalkMgmtService {

    @Resource
    private TDingTalkMgmtMapper tDingTalkMgmtMapper;

    @PostConstruct
    public void init(){
        resetDingTalkCache();
    }

    @Override
    public void resetDingTalkCache() {
        // 清空缓存
        RedisCacheUtils.clearCache(CacheConstants.DING_TALK_REDIS_KEY + "*");
        // 加载缓存
        RedisCacheUtils.setCacheObject(CacheConstants.DING_TALK_REDIS_KEY, tDingTalkMgmtMapper.getNormalDingTalk());
    }
}
